package com.itheima.hashset;

public class Teacher
{

    private int  age;
    private int  tizhong;

    public Teacher() {
    }


    public Teacher(int age, int tizhong) {
        this.age = age;
        this.tizhong = tizhong;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getTizhong() {
        return tizhong;
    }

    public void setTizhong(int tizhong) {
        this.tizhong = tizhong;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "age=" + age +
                ", tizhong=" + tizhong +
                '}';
    }
    // 如果  两个对象的哈希值相同, 需要重写equals方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Teacher teacher = (Teacher) o;

        if (age != teacher.age) return false;
        return tizhong == teacher.tizhong;
    }
    //哈希值 有可能  相同
    @Override
    public int hashCode() {
        return age+tizhong;
    }
}
